package org.mxp.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.mxp.config.ConfirmConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消费者
 */
@Slf4j
@Component
public class MsgConsumer {

    @RabbitListener(queues = ConfirmConfig.CONFIRM_QUEUE_NAME)
    public void receive1(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("{} 队列消费消息：{}", ConfirmConfig.CONFIRM_QUEUE_NAME, msg);
    }

    @RabbitListener(queues = ConfirmConfig.BACKUP_QUEUE_NAME)
    public void receive2(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("{} 队列消费消息：{}", ConfirmConfig.BACKUP_QUEUE_NAME, msg);
    }

    @RabbitListener(queues = ConfirmConfig.WARNING_QUEUE_NAME)
    public void receive3(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("{} 队列消费消息：{}", ConfirmConfig.WARNING_QUEUE_NAME, msg);
    }
}
